let express = require('express');
let router = express.Router();
let filter = require('../../components/filter');

/**
 * 查询科目数据 by p 2018-06-11
 *
 * 按条件查询科目数据
 *
 */
router.get('/', filter.authorize, function (req, res, next) {
    req.app.db.query("select id, name from role", [], function (err, results) {
        if (err) {
            res.json({"success": false, "message": global.databaseErr, "detail": err});
            return;
        }

        if (results.length === 0) {
            res.json({"success": false, "message": "用户角色信息错误！"});
            return;
        }

        res.json({"success": true, "data":{"role": results, "active": [{"key": 0, "value": "不可用"}, {"key": 1, "value": "可用"}], "questionType": [{"key": 0, "value": "单选题"}, {"key": 1, "value": "多选题"}]}, "message": ""});
    });
});

module.exports = router;